#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=200;
typedef long long LL;
bool vis[maxn][maxn];
LL a[maxn][maxn];
void f(LL **b){
    b[]
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n,m;cin>>n>>m;
    memset(a,0,sizeof(a));memset(vis,0,sizeof(vis));
    for(LL i=1;i<=n;i++){
        for(LL j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    for(LL i=1;i<=n;i++){
        for(LL j=1;j<=m;j++){
            if( (i+j)%2==1){
                if(a[i][j]%2==0){
                    a[i][j]++;
                }
            }
            if((i+j)%2==0){
                if(a[i][j]%2==1){
                    a[i][j]++;
                }
            }
        }
    }
    for(LL i=1;i<=n;i++){
        for(LL j=1;j<=m;j++){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    ///cout<<endl;
  }
return 0;
}
